package com.hongkzh.www.sell.controller;

import com.google.common.collect.Lists;
import com.hongkzh.www.conmon.BaseController;
import com.hongkzh.www.conmon.DateUtil;
import com.hongkzh.www.conmon.ReqResponse;
import com.hongkzh.www.mediaShop.service.MediaShopService;
import com.hongkzh.www.shop.service.ProductService;
import com.hongkzh.www.swagger.annotation.*;
import com.hongkzh.www.user.service.UserService;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.upload.UploadFile;

import java.util.List;

/**
 * @author martins
 */
@Api(tag = "sell", description = "售卖管理")
public class SellController extends BaseController {
    MediaShopService mediaShopService=new MediaShopService();
    ProductService productService=new ProductService();
    /**
     * 上传文件基础虚拟路径
     */
    public static final String USERFILES_BASE_URL = "/userfiles/1/images/afterSell/";

    /**
     * 我的商品
     */
    @ApiOperation(url = "/v1/sell/myUpperProduct", tag = "sell", httpMethod = "post",description = "出售中商品列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "order", description = "1 添加时间2销量 3交易额4 库存", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "productId产品id createDate 创建时间 title 标题 imgSrc 主图 " +
                            " price 价格 num数量 orderNum购买数 money 成交额 dayVisitor今日访客  daySales 今日销量"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void myUpperProduct(){
        String loginUid=getAttr("loginUid");
        String order=getPara("order");
        int pageNumber=getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r=new ReqResponse();
        Page<Record> record= mediaShopService.myUpperProduct(loginUid,pageNumber,"1",order);

        r.setData(record);
        renderJson(r);
    }
    /**
     * 我的商品
     */
    @ApiOperation(url = "/v1/sell/myLowerProduct", tag = "sell", httpMethod = "post",description = "已下架商品列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "order", description = "1 添加时间2销量 3交易额4 库存", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "productId产品id createDate 创建时间 title 标题 imgSrc 主图" +
                            "price 价格 num数量 orderNum购买数 money 成交额"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void myLowerProduct(){
        String loginUid=getAttr("loginUid");
        String order=getPara("order");
        int pageNumber=getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r=new ReqResponse();
        Page<Record> record= mediaShopService.myUpperProduct(loginUid,pageNumber,"0",order);

        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/sell/upperLowerProduct", tag = "sell", httpMethod = "post",description = "商品上下架")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "productId", description = "产品id", required = true, dataType = "string"),
            @Param(name = "state", description = "1上架0下架", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = " "),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void upperLowerProduct(){
        String loginUid=getAttr("loginUid");
        String productId=getPara("productId");
        String state=getPara("state");
        ReqResponse<String> r=new ReqResponse();
        enhance(MediaShopService.class).upperLowerProduct(loginUid,productId,state);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/myAllProduct", tag = "sell", httpMethod = "post",description = "搜索商品列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "title", description = "内容", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "productId产品id createDate 创建时间 title 标题 imgSrc 主图" +
                            "price 价格 num数量 orderNum购买数 money 成交额 isupper 1上架0下架"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void myAllProduct(){
        String loginUid=getAttr("loginUid");
        String title=getPara("title");
        int pageNumber=getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r=new ReqResponse();
        Page<Record> record= mediaShopService.myAllProduct(loginUid,pageNumber,title);

        r.setData(record);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/sellerorderList", tag = "sell", httpMethod = "post", description = "订单搜索")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "title", description = "标题", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description =" orderNumber 订单号  currentTime 当前时间 " +
                            "   state 订单状态 1 等待付款 2 确定订单   3 已支付  4 已发货 5 已收货 6 暂存储 7 已完成  8 已取消  9 已转售 10 已关闭 11乐币支付12现金支付 100待分享" +
                                    "  integral乐币 freightIntegral 运费乐币 mediaUserId 商户id name 商户名称 headImg 商户头像 subList 订单商品[colorName 颜色名称 " +
                                    "   orderNumber 订单号 title 标题 activityPrice活动价格 activityType 活动类型 1爆款 2 秒杀 3折扣 " +
                                    "  productId 商品id imgSrc 商品图 skuId  limitTime 支付限制时间 number  数量  " +" afterState 售后状态 10申请退款 20 取消退款 30 同意退款 40拒绝退款 " +
                                    " 45退款完成 50买家退货投诉 55买家取消投诉 " +
                                    "60申请退货退款 65取消退货退款70同意退货退款 " +
                                    "80拒绝退货退款 90退货退款完成100买家举证110卖家举证 120平台同意 125平台拒绝 130买家退款投诉 135 投诉解决" +
                                    "  specName规格名称 mediaUserId 商户id  integral 乐币  ] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void sellerorderList() {
        String loginUid = getAttr("loginUid");
        String title = getPara("title");
        int pageNumber=getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r=new ReqResponse();
        Page<Record> record= mediaShopService.sellerorderList(loginUid,pageNumber,title);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/sell/getMediaProductById", tag = "sell", httpMethod = "post",description = "个人商品详情")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "productId", description = "产品id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{ categoryId 分类id  categoryName 分类名称 freightName 运费名称 productId 产品id  title 标题 subtitle 副标题 integral 价格   descript 详情" +
                            "    images [imgSrc 图 imgId  图片id] 主轮播图 freightId 运费id freight 运费  " +
                            " skus [model 规格  sukId sku的id num 库存 price 价格 ]  }"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getMediaProductById(){
        String loginUid=getAttr("loginUid");
        String productId=getPara("productId");
        ReqResponse<Record> r=new ReqResponse();
        Record record=productService.getMediaProductByProductId(productId,loginUid);
        r.setData(record);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/deleteProductByImgId", tag = "sell", httpMethod = "post",description = "删除商品图片")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "imgId", description = "图片id逗号隔开", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = " "),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void deleteProductByImgId(){
        String loginUid=getAttr("loginUid");
        String imgId=getPara("imgId");
        ReqResponse<Record> r=new ReqResponse();
      enhance(ProductService.class).deleteProductByImgId(loginUid,imgId);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/deleteSku", tag = "sell", httpMethod = "post",description = "删除sku")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "skuId", description = "skuId 逗号隔开", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = " "),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void deleteSku(){
        String loginUid=getAttr("loginUid");
        String skuId=getPara("skuId");
        ReqResponse<Record> r=new ReqResponse();
        enhance(ProductService.class).deleteSku(loginUid,skuId);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/deleteProduct", tag = "sell", httpMethod = "post",description = "删除商品")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "productId", description = "productId", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = " "),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void deleteProduct(){
        String loginUid=getAttr("loginUid");
        String productId=getPara("productId");
        ReqResponse<Record> r=new ReqResponse();
        enhance(ProductService.class).deleteProduct(loginUid,productId);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/sellerorderListByState", tag = "sell", httpMethod = "post", description = "订单列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "state", description = "订单状态 1 等待付款 2 确定订单   3 已支付  4 已发货 5 已收货 6 暂存储 7 已完成  8 已取消  9 已转售 10 已关闭 ", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " orderNumber 订单号  currentTime 当前时间 " +
                            "   state 订单状态 1 等待付款 2 确定订单   3 已支付  4 已发货 5 已收货 6 暂存储 7 已完成  8 已取消  9 已转售 10 已关闭 11乐币支付12现金支付 100待分享" +
                            "  integral乐币 freightIntegral 运费乐币 mediaUserId 商户id name 商户名称 headImg 商户头像 subList 订单商品[colorName 颜色名称 " +
                            "   orderNumber 订单号 title 标题 activityPrice活动价格 activityType 活动类型 1爆款 2 秒杀 3折扣 " +
                            "  productId 商品id imgSrc 商品图 skuId  limitTime 支付限制时间 number  数量  " +" afterState 售后状态 10申请退款 20 取消退款 30 同意退款 40拒绝退款 " +
                            " 45退款完成50买家投诉 55买家取消投诉 " +
                            "60申请退货退款 65取消退货退款70同意退货退款 " +
                            "80拒绝退货退款 90退货退款完成100买家举证110卖家举证" +
                            "  specName规格名称 mediaUserId 商户id  integral 乐币  ] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void sellerorderListByState() {
        String loginUid = getAttr("loginUid");
        String state = getPara("state");
        int pageNumber=getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r=new ReqResponse();
        Page<Record> record= mediaShopService.sellerorderListByState(loginUid,pageNumber,state);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/sell/sellerorderListByTransaction", tag = "sell", httpMethod = "post", description = "交易中订单")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " orderNumber 订单号 integral乐币  subList 订单商品[   imgSrc 商品图  ]  confirmDate 完成时间 consignee 用户名称"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void sellerorderListByTransaction() {
        String loginUid = getAttr("loginUid");
        int pageNumber=getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r=new ReqResponse();
        Page<Record> record= mediaShopService.sellerorderListByTransaction(loginUid,pageNumber);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/sell/sellerorderListBySettlement", tag = "sell", httpMethod = "post", description = "结算中订单")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " orderNumber 订单号 integral乐币  subList 订单商品[   imgSrc 商品图  ]  confirmDate 完成时间 consignee 用户名称"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void sellerorderListBySettlement() {
        String loginUid = getAttr("loginUid");
        int pageNumber=getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r=new ReqResponse();
        Page<Record> record= mediaShopService.sellerorderListBySettlement(loginUid,pageNumber);
        r.setData(record);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/sell/sellerorderFlow", tag = "sell", httpMethod = "post", description = "订单流水")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "state", description = "0全部 1收入2支出3冻结", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " orderNumber 订单号 integral乐币  subList 订单商品[   imgSrc 商品图  ]  confirmDate 完成时间 consignee 用户名称   afterState 有值表示支出 "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void sellerorderFlow() {
        String loginUid = getAttr("loginUid");
        String state = getPara("state");
        int pageNumber=getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r=new ReqResponse();
        Page<Record> record= mediaShopService.sellerorderFlow(loginUid,pageNumber,state);
        r.setData(record);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/sellerorderListHeader", tag = "sell", httpMethod = "post", description = "订单头部")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string")

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " deliveryCount待发货 paymentfCount 代付款shippedCount已发货 salecCount售后"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void sellerorderListHeader() {
        String loginUid = getAttr("loginUid");
        ReqResponse<Record> r=new ReqResponse();
       Record record= mediaShopService.sellerorderListHeader(loginUid);
        r.setData(record);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/myseller", tag = "sell", httpMethod = "post", description = "我的售卖")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string")

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " visitors访客数  integral 今日付款金额 completeCount 完成订单数 payCount 付款订单 deliveryCount待发货 refundsCount待退款 "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void myseller() {
        String loginUid = getAttr("loginUid");
        ReqResponse<Record> r=new ReqResponse();
        Record record= mediaShopService.myseller(loginUid);
        r.setData(record);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/sellerupdateorderprice", tag = "sell", httpMethod = "post", description = "修改订单价格")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "integral", description = "总乐币", required = true, dataType = "string"),
            @Param(name = "freightIntegral", description = "运费乐币", required = true, dataType = "string"),
            @Param(name = "productintegral", description = "商品乐币", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void sellerupdateorderprice() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        int integral = getParaToInt("integral");
        int freightIntegral = getParaToInt("freightIntegral");
        int productintegral = getParaToInt("productintegral");
        ReqResponse<Record> r=new ReqResponse();
        if(integral!=(freightIntegral+productintegral)){
            r.setCode(1);
            r.setMsg("总金额不对");
        }
        else {
              enhance(MediaShopService.class).sellerupdateorderprice(loginUid,orderNumber,integral,freightIntegral,productintegral);

          }

        renderJson(r);
    }

    @ApiOperation(url = "/v1/sell/sellerupdatecloseorder", tag = "sell", httpMethod = "post", description = "关闭订单价格")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "reason", description = "原因", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void sellerupdatecloseorder() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        String reason = getPara("reason");
        ReqResponse<Record> r=new ReqResponse();
        enhance(MediaShopService.class).sellerupdatecloseorder(loginUid,orderNumber,reason);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/sell/orderAfterSale", tag = "sell", httpMethod = "post", description = "订单售后进度")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description =  "complaintsImgs投诉图片 [imgSrc] " +
                            "buyerImgs 买家举证图片 [imgSrc] sellerImgs 卖家举证 [imgSrc] cancelDate 取消退款日期 cancelRefundDate 取消退货退款日期 refuserefundImgs 拒绝退款 [imgSrc]" +
                            "type1退款2退货退款 limitDate 限制退款时间 currentTime 现在时间 afterState 售后状态 10申请退款 20 取消退款 30 同意退款 40拒绝退款 " +
                            " 45退款完成50买家投诉 55买家取消投诉  60申请退货退款 65取消退货退款 66 已发退货快递  70同意退货退款 80拒绝退货退款 90退货退款完成100买家举证110卖家举证 " +
                            " afterId 售后id   refundcontact退款联系人  refundReason退款原因  refundTelephone 退款电话" +
                            "applyDate 申请日期 approvalRefundDate 同意退款日期" +
                            "refundsDate 退款成功日期 refundAmount退款金额  complaintReason投诉原因 complaintDesc 投诉描述" +
                            " complaintDate 投诉日期 cancelcomplaintDate 取消投诉日期 refuserefundReason 拒绝退款原因 refuserefundDate 拒绝退款日期" +
                            "refusereGoodsReason拒绝退货原因 refuseGoodsDate 拒绝退货日期 refuseregoodsImgs 拒绝退货图片[imgSrc]" +
                            "buyerProof 买家举证 buyerProofDate 买家举证日期 buyerProofDesc 买家举证描述 agreeRefundDate 同意退货退款日期 consignee 收件人" +
                            "phone电话 provinceId 省份id cityId城市id area_id 区id address 地址 courierDate快递日期 courier 快递公司 courierNumber 快递单号" +
                            " sellerProof 卖家举证 sellerProofDate 卖家举证日期 sellerProofDesc 卖家举证描述"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void orderAfterSale() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<Record> r=new ReqResponse();
        Record record= mediaShopService.orderAfterSale(loginUid,orderNumber);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/sell/sellerApprovalOrder", tag = "sell", httpMethod = "post", description = "同意退款")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void sellerApprovalOrder() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<Record> r=new ReqResponse();
        enhance(MediaShopService.class).sellerApprovalOrder(loginUid,orderNumber);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/sell/sellerRefuseOrder", tag = "sell", httpMethod = "post", description = "拒绝退款(带图片)")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "refundReason", description = "拒绝原因", required = true, dataType = "string"),
            @Param(name = "imgSrc", description = "图片数组", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })

    public void sellerRefuseOrder() {
        List<UploadFile> list=  getFiles();
        getResponse().addHeader("Access-Control-Allow-Origin", "*");
        String loginUid = getAttr("loginUid");
        String refundReason = getPara("refundReason");
        String orderNumber = getPara("orderNumber");
        List<String> imgs=Lists.newArrayList();
        String coverImgSrc=null;
        for (UploadFile u:list
                ) {
            coverImgSrc= USERFILES_BASE_URL +DateUtil.FormatDateMMDD()+"/";
            coverImgSrc=getFilePath(coverImgSrc,u);
            imgs.add(coverImgSrc);
        }
        ReqResponse<Record> r=new ReqResponse();
        enhance(MediaShopService.class).sellerRefuseOrder(loginUid,orderNumber,refundReason,imgs);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/sell/sellerRefuseOrderNotImg", tag = "sell", httpMethod = "post", description = "拒绝退款(不带图片)")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "refundReason", description = "拒绝原因", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void sellerRefuseOrderNotImg() {
        String loginUid = getAttr("loginUid");
        String refundReason = getPara("refundReason");
        String orderNumber = getPara("orderNumber");
        ReqResponse<Record> r=new ReqResponse();
        enhance(MediaShopService.class).sellerRefuseOrder(loginUid,orderNumber,refundReason,null);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/mysellAfterSale", tag = "sell", httpMethod = "post",description = "售后退货")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "   orderNumber 订单号  currentTime 当前时间 " +
                            "   state 订单状态 1 等待付款 2 确定订单   3 已支付  4 已发货 5 已收货 6 暂存储 7 已完成  8 已取消  9 已转售 10 已关闭11乐币支付12现金支付 100待分享 " +
                            "  integral乐币 freightIntegral 运费乐币 mediaUserId 商户id name 商户名称 headImg 商户头像 subList 订单商品[colorName 颜色名称 " +
                            "   orderNumber 订单号 title 标题 activityPrice活动价格 activityType 活动类型 1爆款 2 秒杀 3折扣 " +
                            "  productId 商品id imgSrc 商品图 skuId  limitTime 支付限制时间 number  数量  " +" afterState 售后状态 10申请退款 20 取消退款 30 同意退款 40拒绝退款 " +
                            " 45退款完成50买家投诉 55买家取消投诉 " +
                            "60申请退货退款 65取消退货退款70同意退货退款 " +
                            "80拒绝退货退款 90退货退款完成100买家举证110卖家举证" +
                            "  specName规格名称 mediaUserId 商户id  integral 乐币   ] "),
                    @ResponseHeader(name="msg",description = "失败原因") })
    })
    public void mysellAfterSale() {
        String loginUid=getAttr("loginUid");
        int pageNumber=getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r=new ReqResponse();
        Page<Record> p=mediaShopService.mysellAfterSale(loginUid,pageNumber);
        r.setData(p);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/expresList", tag = "sell", httpMethod = "post", description = "快递公司")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " name 名称 abbreviation 简称"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void expresList() {
        String loginUid = getAttr("loginUid");
        ReqResponse<List<Record>> r=new ReqResponse();
        r.setData(mediaShopService.expresList(loginUid));
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/sellerOrderDeliver", tag = "sell", httpMethod = "post", description = "发货")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "courier", description = "快递公司", required = true, dataType = "string"),
            @Param(name = "courierNumber", description = "单号", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void sellerOrderDeliver() {
        String loginUid = getAttr("loginUid");
        String express = getPara("courier");
        String orderNumber = getPara("orderNumber");
        String expressNumber = getPara("courierNumber");
        ReqResponse<Record> r=new ReqResponse();
        enhance(MediaShopService.class).sellerOrderDeliver(loginUid,orderNumber,express,expressNumber);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/sell/sellerOrderAddress", tag = "sell", httpMethod = "post", description = "修改订单地址")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "consignee", description = "收货", required = true, dataType = "string"),
            @Param(name = "phone", description = "电话", required = true, dataType = "string"),
            @Param(name = "address", description = "地址", required = true, dataType = "string"),
            @Param(name = "provinceId", description = "省份id", required = true, dataType = "string"),
            @Param(name = "cityId", description = "城市id", required = true, dataType = "string"),
            @Param(name = "areaId", description = "区id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void sellerOrderAddress() {

        String loginUid=getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        String consignee=getPara("consignee");
        String phone=getPara("phone");
        String address=getPara("address");
        String provinceId=getPara("provinceId");
        String cityId=getPara("cityId");
        String areaId=getPara("areaId");

        ReqResponse<Record> r=new ReqResponse();
        enhance(MediaShopService.class).sellerOrderAddress(loginUid,orderNumber,consignee,phone,address,provinceId,cityId,areaId);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/sell/addUserReturnAddress", tag = "sell", httpMethod = "post",description = "售后-增加或者修改用户退货地址")
    @Params({

            @Param(name = "addressId", description = "地址id", required = false, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "consignee", description = "收货", required = true, dataType = "string"),
            @Param(name = "phone", description = "电话", required = true, dataType = "string"),
            @Param(name = "address", description = "地址", required = true, dataType = "string"),
            @Param(name = "isDefault", description = "是否默认 1是 0否", required = true, dataType = "string"),
            @Param(name = "provinceId", description = "省份id", required = true, dataType = "string"),
            @Param(name = "cityId", description = "城市id", required = true, dataType = "string"),
            @Param(name = "areaId", description = "区id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = " "),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void addUserReturnAddress(){
        String addressId=getPara("addressId");
        String loginUid=getAttr("loginUid");
        String consignee=getPara("consignee");
        String phone=getPara("phone");
        String address=getPara("address");
        String isDefault=getPara("isDefault");
        String provinceId=getPara("provinceId");
        String cityId=getPara("cityId");
        String areaId=getPara("areaId");

        UserService userService=enhance(UserService.class);
        ReqResponse<String> r=new ReqResponse();
        try {
            userService.addUserReturnAddress(addressId,loginUid,consignee,phone,address,isDefault,provinceId,cityId,areaId);
        }catch (Exception e){
            e.printStackTrace();
            r.setCode(1);
            r.setData("保存失败");
        }

        r.setData("");
        renderJson(r);
    }
    @ApiOperation(url = "/v1/sell/deleteUserReturnAddress", tag = "sell", httpMethod = "post",description = "售后-删除用户退货地址")
    @Params({

            @Param(name = "addressId", description = "地址id", required = false, dataType = "string"),
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),


    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = " "),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void deleteUserReturnAddress(){
        String addressId=getPara("addressId");
        String loginUid=getAttr("loginUid");
        UserService userService=enhance(UserService.class);
        ReqResponse<String> r=new ReqResponse();
        try {
            userService.deleteUserReturnAddress(addressId,loginUid);
        }catch (Exception e){
            e.printStackTrace();
            r.setCode(1);
            r.setData("保存失败");
        }
        r.setData("");
        renderJson(r);
    }

    @ApiOperation(url = "/v1/sell/getUserReturnAddressList", tag = "sell", httpMethod = "post",description = "售后-用户退货地址")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{ addressId 地址id uid 用户id consignee收货人  phone 电话 address 地址 isDefault 是否默认 1是 0否 " +
                            "provinceId 省份id provinceName 省份名称 cityId城市id  cityName 城市名称 areaId 区id areaName 区名称 }"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getUserReturnAddressList(){
        String loginUid=getAttr("loginUid");
        UserService userService=new UserService();
        ReqResponse<List<Record>> r=new ReqResponse();
        List<Record> records=userService.getUserReturnAddressList(loginUid);
        r.setData(records);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/sell/agreeReturnGoods", tag = "sell", httpMethod = "post",description = "同意退货")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "addressId", description = "地址id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = " "),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void agreeReturnGoods(){
        String loginUid=getAttr("loginUid");
        String addressId=getPara("addressId");
        String orderNumber=getPara("orderNumber");
        ReqResponse<Record> r=new ReqResponse();
        enhance(MediaShopService.class).agreeReturnGoods(loginUid,addressId,orderNumber);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/sell/refuseReturnGoods", tag = "sell", httpMethod = "post", description = "拒绝退货")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "refundReason", description = "拒绝原因", required = true, dataType = "string"),
            @Param(name = "imgSrc", description = "图片数组", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })

    public void refuseReturnGoods() {
        List<UploadFile> list=  getFiles();
        getResponse().addHeader("Access-Control-Allow-Origin", "*");
        String loginUid = getAttr("loginUid");
        String refundReason = getPara("refundReason");
        String orderNumber = getPara("orderNumber");
        List<String> imgs=Lists.newArrayList();
        String coverImgSrc=null;
        for (UploadFile u:list
                ) {
            coverImgSrc= USERFILES_BASE_URL +DateUtil.FormatDateMMDD()+"/";
            coverImgSrc=getFilePath(coverImgSrc,u);
            imgs.add(coverImgSrc);
        }
        ReqResponse<Record> r=new ReqResponse();
        enhance(MediaShopService.class).refuseReturnGoods(loginUid,orderNumber,refundReason,imgs);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/sell/sellerProof", tag = "sell", httpMethod = "post", description = "商家举证")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "sellerProof", description = "商家举证原因", required = true, dataType = "string"),
            @Param(name = "sellerProofDesc", description = "商家举证说明", required = true, dataType = "string"),
            @Param(name = "imgSrc", description = "图片数组", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })

    public void sellerProof() {
        List<UploadFile> list=  getFiles();
        getResponse().addHeader("Access-Control-Allow-Origin", "*");
        String loginUid = getAttr("loginUid");
        String sellerProof = getPara("sellerProof");
        String orderNumber = getPara("orderNumber");
        String sellerProofDesc = getPara("sellerProofDesc");
        List<String> imgs=Lists.newArrayList();
        String coverImgSrc=null;
        for (UploadFile u:list
                ) {
            coverImgSrc= USERFILES_BASE_URL +DateUtil.FormatDateMMDD()+"/";
            coverImgSrc=getFilePath(coverImgSrc,u);
            imgs.add(coverImgSrc);
        }
        ReqResponse<Record> r=new ReqResponse();
        enhance(MediaShopService.class).sellerProof(loginUid,orderNumber,sellerProof,imgs,sellerProofDesc);
        renderJson(r);
    }
}
